//
// Created by stramek on 26.02.17.
//
#ifndef PROJEKTMAGISTERSKI_CONSTANTS_H
#define PROJEKTMAGISTERSKI_CONSTANTS_H

#include <Eigen/Dense>

using namespace Eigen;

#define CLASS_NUM 3
#define MIN_PLANES_NUM 3
#define MAX_ANGLE_BETWEEN_TWO_PLANES 0.1 // 这个参数决定了是否能迭代完成，和优化的效果如何
#define MAX_ANGLE_BETWEEN_TWO_PLANES_LOOSE 0.3
#define MAX_ANGLE_BETWEEN_TWO_PLANES_SMALL_WALL 0.8 // 为小面积的墙体设置一个专门的阈值

#define MAX_ITERATIONS 500
//------------predefine-------------------------
#define FILE_READ_ERROR -1
#define ALLOC_ERROR -1
#define NORMAL_STATUS 2
#define LEN_FILE_NAME 260
#define NEW_TRAJ 0

//-------------debug switch-------------------------------
#define TEST 0    //提交程序时设为0

enum LABEL_TYPE
{
    CEILING, FLOOR, WALL, CLUTTER
};

const static float PCA_MAX_ACCEPTED_DISTANCE = 0.005f;
const static float CLUSTERING_MAX_ANGLE_THRESHOLD = 20.0;
const static double CLUSTERING_MAX_DISTANCE_THRESHOLD = 0.5;
const static int MAX_SIMILARITY_VALUE = 15;
const static int MAX_ANGLE_BETWEEN_PLANES = 15;
const static double MAX_DISTANCE_BETWEEN_PLANES = 0.5;
const static int VALID_ANGLE_BETWEEN_PLANES = 80;

const static int MAX_SIMILARITY_GLOBAL_MAP_VALUE = 15;

// 合并平面时使用的阈值
const static float MAX_ANGLE_BETWEEN_EQUAL_PlANES = 7.0; // 3.5;
const static float D_THRESHOLD_BETWEEN_EQUAL_PLANES = 0.18; // 0.15;

// 判断两个平面的中心是否足够靠近的阈值
const static float THRESHOLD_BETWEEN_PLANE_CENTER = 3.0; // 这是墙面的阈值
const static float THRESHOLD_BETWEEN_PLANE_CENTER2 = 10.0; // 这是地面和天花板的阈值 

// 关联平面的阈值
const static int MAX_ANGLE_BETWEEN_PLANES_GLOBAL_MAP = 20;
//const float D_THRESHOLD = 0.3;
const float D_THRESHOLD = 0.5;

const static double MAX_DISTANCE_BETWEEN_PLANES_GLOBAL_MAP = 0.5;
// 判断是否和z轴平行
const static int MAX_ANGLE_BETWEEN_Z_AXIS = 10;

const static int NUMBER_OF_POINTS_TO_COUNT_DISTANCE = 50;

const static float MAX_PERCENT_OF_NAN_PIXELS_INSIDE_PLAIN = 20.0f;

const static float G2O_MAX_DISPLACEMENT = 0.1;
const static float G2O_MAX_ROTATION = 5;


const double FOCAL_LENGTH_X = 525;
const double FOCAL_LENGTH_Y = 525;
const double OPTICAL_CENTER_X = 319.5;
const double OPTICAL_CENTER_Y = 239.5;

const Matrix<double, 3, 3> PHCP_MODEL = [] {
    Matrix<double, 3, 3> matrix;
    matrix << 1 / FOCAL_LENGTH_X, 0, -OPTICAL_CENTER_X / FOCAL_LENGTH_X,
            0, 1 / FOCAL_LENGTH_Y, -OPTICAL_CENTER_Y / FOCAL_LENGTH_Y,
            0, 0, 1;
    return matrix;
}();

const  int IMAGE_HEIGHT = 480;

static int SCREENSHOT_HELPER = 1;

const double G2O_Z_OFFSET = -2.5;

static int HELPER_ITERATION = 0;

#endif //PROJEKTMAGISTERSKI_CONSTANTS_H